<?php 
/**
 * Joomla! 1.5 component arts_curriculum $Id: view.feed.php
 * @package    arts_curriculum
 * @version		
 * @subpackage
 * @author     Chris Borkowski {@link http://www.guggenheim.org}
 * @author     Created on 1-August-2010
 * @author     Modified on 04-December-2010
 */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.view');

/**
* RSS FEED View class for the arts_curriculum component
* @package Arts_curriculum
*/

class Arts_curriculumViewCategory extends JView

{
	function display()
	{
		global $mainframe;

		$document =& JFactory::getDocument();
		$params =& $mainframe->getParams();
		$feedEmail = (@$mainframe->getCfg('feed_email')) ? $mainframe->getCfg('feed_email') : 'author';
		$siteEmail = $mainframe->getCfg('mailfrom');

		// Get some data from the model
		JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
		$category	= & $this->get( 'Category' );
		$rows 		= & $this->get( 'Data' );
		
		$document->setTitle('Arts Curriculum Exhibition: '.$this->escape($category->title));
	
		//do a lot of prep work	
		$description = strip_tags(html_entity_decode(preg_replace('/{ac-break}(.*)|(\n)(.*){1,}/', '', $this->escape($category->description))));
		$document->setDescription($description);
		
		//strip this out
		$tags = array('{ac-thumbcap}','{/ac-thumbcap}');
		foreach ( $rows as $row )
		{
			$link = JRoute::_( 'index.php?view=item&catid='.$category->slug.'&id='. $row->id);			
			$author			= $row->created_by_alias;
			// load individual item creator class
			$item = new JFeedItem();
			$item->title 		= 'Theme: '. $this->escape($row->title);
			$item->link 		= $link;
			$item->description  =  '<img src="/images/content/arts_curriculum/derivative1/'.$row->image1 .'"><br>'; 
			$item->description .= '<em>'.$row->imgcap1.'</em>';
			$item->description .= str_replace($tags, '', $row->main_body);
			$item->date			= $row->created;
			$item->category   	= $this->escape($category->title);
			$item->author		= $author;
			$document->addItem( $item );
		}//end foreach

	}//end function

}//end class
